import { get, post } from '@/utils/http'

enum API {
  // 获取产品管理员
  GETPADMINLIST_API = '/admin/getAdminList',
  // 添加产品管理员
  ADDADMIN_API = '/admin/addAdmin',
  // 编辑产品管理员
  UPDATEADMIN_API = '/admin/updateAdmin',
  // 权限变更
  UPDATEADMININDENTITY_API = '/admin/updateIdentity',
  // 搜索用户
  SEARCHUSER_API = '/admin/searchUser',
  // 冻结/解冻 用户
  BANORUNFREEZEUSER_API = '/admin/banStatus',
  // 获取冻结用户列表
  GETBANLIST_API = '/admin/getBanList',
  // 获取部门信息
  GETDEPARTMENT_API = '/admin/getDepartment',
  // 获取产品信息
  GETPRODUCT_API = '/admin/getProduct',
  // 设置部门信息
  UPDATEDEPARTMENT_API = '/admin/updateDepartment',
  // 设置产品信息
  UPDATEPRODUCT_API = '/admin/updateProduct',
  // 删除用户
  DELETEUSER_API = '/admin/deleteUser',
  // 根据部门筛选
  SEARCHEPARTMENT_API = '/admin/searchDepartment',
  // 同时筛选冻结用户 部门
  SEARCHEPARTMENTANDSTATUS_API = '/admin/searchDepartmentAndStatus'
}
// 获取用户列表
export const getAdminListAPI = (identity: string, page: number) => {
  return get<AdminInfo[]>(API.GETPADMINLIST_API, { params: { identity, page } })
}

// 添加产品管理员
export const addAdminAPI = (data: UserAdmin, identity: string) => {
  return post<void>(API.ADDADMIN_API, { ...data, identity })
}

// 编辑产品管理员
export const updateAdminAPI = (data: UserAdmin) => {
  return post<void>(API.UPDATEADMIN_API, data)
}

// 权限变更
export const updateIdentityAPI = (id: number, identity: string) => {
  return post<void>(API.UPDATEADMININDENTITY_API, { id, identity })
}

// 搜索用户
export const SearchUserAPI = (account: number, identity: string) => {
  return get<AdminInfo[]>(API.SEARCHUSER_API, { params: { account, identity } })
}

// 冻结/解冻 用户
export const ChangeStatusAPI = (status: number, id: number) => {
  return post<void>(API.BANORUNFREEZEUSER_API, { status, id })
}

// 获取冻结用户列表
export const getBanListAPI = (page: number) => {
  return get<AdminInfo[]>(API.GETBANLIST_API, { params: { page } })
}

// 根据部门筛选
export const searchDepartmentAPI = (page: number, department: string | undefined) => {
  return get<AdminInfo[]>(API.SEARCHEPARTMENT_API, { params: { page, department } })
}

// 同时筛选冻结用户 部门
export const searchDepartmentAndStatusAPI = (page: number, department: string | undefined) => {
  return get<AdminInfo[]>(API.SEARCHEPARTMENTANDSTATUS_API, { params: { page, department } })
}

// 获取部门信息
export const getDepartmentAPI = () => {
  return get<string>(API.GETDEPARTMENT_API)
}

// 获取产品信息
export const getProductAPI = () => {
  return get<string>(API.GETPRODUCT_API)
}

// 设置部门信息
export const updateDepartmentAPI = (department: string) => {
  return post<void>(API.UPDATEDEPARTMENT_API, { department })
}

// 设置产品信息
export const updateProductAPI = (product: string) => {
  return post<void>(API.UPDATEPRODUCT_API, { product })
}

// 删除用户
export const deleteUserAPI = (id: number, account: number) => {
  return post<void>(API.DELETEUSER_API, { id, account })
}
